为什么Python比C++慢很多?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# include <cstdio>



int n = 15 ;
int cnt ;



void Dfs ( int row, int shu, int pie, int na ) {
int ave = ((1 << n) - 1) & ~(shu | pie | na) ;
while ( ave ) {
int p = ave & -ave ;
ave ^= p ;
if ( row == n )
++ cnt ;
else
Dfs ( row + 1, shu | p, (pie | p) >> 1, (na | p) << 1 ) ;
}
}

int main ( ) {
Dfs ( 1, 0, 0, 0 ) ;
printf ( "%d\n", cnt ) ;
}